#TODO: url() need to be refactored in decorator pattern  ???

from typing import Any
from bcat.rpc.server.server import Server
from jsonrpc.backend.flask import api 
class FlaskServerWrapper(Server):
    def __init__(self, server: Server):
        super().__init__(server.url() + '/api')
        self.__server = server
        print(self.url())

    def register(self, method: str, f: Any) -> bool:
        api.dispatcher.add_method(f, method)
        return True

    def unregister(self, method: str) -> bool:
        #TODO:
        return True
    
    def run(self) -> bool:
        self.__server.register('/api', api.as_view())
        self.__server.run()
        return True
